package com.example.bookstore;


import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.Nullable;

public class Book implements Parcelable {
    private int id;
    private String bookPrice;
    private int bookRest;
    private String bookName;
    private String bookTitle;
    private String bookImage;
    private String bookDescribe;
    private String bookPress;
    private String pressDate;
    private String bookAuthor;
    private String bookCategory;

    protected Book(Parcel in) {
        id = in.readInt();
        bookPrice = in.readString();
        bookRest = in.readInt();
        bookName = in.readString();
        bookTitle = in.readString();
        bookImage = in.readString();
        bookDescribe = in.readString();
        bookPress = in.readString();
        pressDate = in.readString();
        bookAuthor = in.readString();
        bookCategory = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(bookPrice);
        dest.writeInt(bookRest);
        dest.writeString(bookName);
        dest.writeString(bookTitle);
        dest.writeString(bookImage);
        dest.writeString(bookDescribe);
        dest.writeString(bookPress);
        dest.writeString(pressDate);
        dest.writeString(bookAuthor);
        dest.writeString(bookCategory);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Book> CREATOR = new Creator<Book>() {
        @Override
        public Book createFromParcel(Parcel in) {
            return new Book(in);
        }

        @Override
        public Book[] newArray(int size) {
            return new Book[size];
        }
    };

    @Override
    public boolean equals(@Nullable Object obj) {
       Book book = (Book)obj;
       if(book.getId()==id){
           return true;
       }else {
           return false;
       }
    }


    public Book(int id, String bookPrice, int bookRest, String bookName, String bookTitle, String bookImage, String bookDescribe, String bookPress, String pressDate, String bookAuthor, String bookCategory) {
        this.id = id;
        this.bookPrice = bookPrice;
        this.bookRest = bookRest;
        this.bookName = bookName;
        this.bookTitle = bookTitle;
        this.bookImage = bookImage;
        this.bookDescribe = bookDescribe;
        this.bookPress = bookPress;
        this.pressDate = pressDate;
        this.bookAuthor = bookAuthor;
        this.bookCategory = bookCategory;
    }

    public Book() {
    }

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", bookPrice='" + bookPrice + '\'' +
                ", bookRest=" + bookRest +
                ", bookName='" + bookName + '\'' +
                ", bookTitle='" + bookTitle + '\'' +
                ", bookImage='" + bookImage + '\'' +
                ", bookDescribe='" + bookDescribe + '\'' +
                ", bookPress='" + bookPress + '\'' +
                ", pressDate='" + pressDate + '\'' +
                ", bookAuthor='" + bookAuthor + '\'' +
                ", bookCategory='" + bookCategory + '\'' +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(String bookPrice) {
        this.bookPrice = bookPrice;
    }

    public int getBookRest() {
        return bookRest;
    }

    public void setBookRest(int bookRest) {
        this.bookRest = bookRest;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getBookTitle() {
        return bookTitle;
    }

    public void setBookTitle(String bookTitle) {
        this.bookTitle = bookTitle;
    }

    public String getBookImage() {
        return bookImage;
    }

    public void setBookImage(String bookImage) {
        this.bookImage = bookImage;
    }

    public String getBookDescribe() {
        return bookDescribe;
    }

    public void setBookDescribe(String bookDescribe) {
        this.bookDescribe = bookDescribe;
    }

    public String getBookPress() {
        return bookPress;
    }

    public void setBookPress(String bookPress) {
        this.bookPress = bookPress;
    }

    public String getPressDate() {
        return pressDate;
    }

    public void setPressDate(String pressDate) {
        this.pressDate = pressDate;
    }

    public String getBookAuthor() {
        return bookAuthor;
    }

    public void setBookAuthor(String bookAuthor) {
        this.bookAuthor = bookAuthor;
    }

    public String getBookCategory() {
        return bookCategory;
    }

    public void setBookCategory(String bookCategory) {
        this.bookCategory = bookCategory;
    }
}
